const controller = require("../controllers/Controller").controller

// pages/TradingAreaCenter/userDetail.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    type: '',
    couponBagId: "",
    pageNumber: 1,
    keyword: "",
    bagDetail: "",
    personList: "",
    timer: '',
    payNum:'',
    useNum:''
  },

  //生命周期函数--监听页面加载
  onLoad: function (options) {
    this.setData({
      couponBagId: options.id,
      type: options.type
    })
  },

  onShow: function () {
    // this.getAccountPayPage()
    this.getActivityDetail()
    this.couponBagPayNumStatistics()
  },

  //获取用户明细
  // getAccountPayPage() {
  //   let value = {}
  //   value.couponBagId = this.data.couponBagId
  //   value.pageNumber = this.data.pageNumber
  //   value.keyword = this.data.keyword
  //   controller.getAccountPayPage(value).then(res => {
  //     this.setData({
  //       personList: res.data.list
  //     })
  //   })
  // },

  //获取用户明细
  couponBagPayNumStatistics() {
    let value = {}
    value.couponBagId = this.data.couponBagId
    controller.couponBagPayNumStatistics(value).then(res => {
      this.setData({
        payNum: res.data.payNum,
        useNum: res.data.useNum,
      })
    })
  },

  //获取礼一卡通详情
  getActivityDetail() {
    controller.getActivityDetail({
      couponBagId: this.data.couponBagId
    }).then(res => {
      let detail = res.data
      // detail.startTime=detail.startTime.split(" ")[0]
      // detail.endTime=detail.endTime.split(" ")[0]
      this.setData({
        bagDetail: detail
      })
    })
  },

  //获取搜索字段
  // getSearchText(e){
  //   let text=e.detail.value
  //   this.setData({
  //     keyword:text
  //   })
  //   if(this.timer)clearTimeout(this.timer)
  //   this.timer = setTimeout(() => {
  //     this.getAccountPayPage()
  //   }, 500);
  // },

  backBtn() {
    wx.navigateBack()
  },
  // toRanking(){
  //   wx.navigateTo({
  //     url: '/pages/TradingAreaCenter/components/rankingList/rankingList?couponBagId='+this.data.couponBagId + "&type=" + this.data.type,
  //   })

  // },




})